package javabase.schoolwork.day6_19;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author fance
 * @date 2018/6/19 23:35
 */
public class AsyServer {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(8888);
        final Socket client = server.accept();

        new Thread(() -> {
            try {
                BufferedReader br = new BufferedReader(new InputStreamReader(
                        client.getInputStream()));
                String str=null;
                while(true) {
                    if((str=br.readLine())!=null) {
                        System.out.println("server: "+str);
                    }

                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
